<template>
	<view class="page">
		<view class="card">
			<view class="card-header">
				<image class="success-icon" mode="aspectFill" src="../../static/img/indexImg/icon_success.png"></image>
				<text class="success-des">{{data.type_text}}</text>
				<text class="money">{{data.money}} {{coin_name}}</text>
			</view>
			<view class="card-body">
				<view class="list">
					<view class="title">{{i18n.type}}</view>
					<view class="value">{{data.type_text}}</view>
				</view>
				<view class="list" >
					<view class="title">{{i18n.currency}}</view>
					<view class="value">{{coin_name || data.coin_name}}</view>
				</view>
				<view class="list" v-if="data.txhash">
					<view class="title">{{i18n.withdraw}}HASH</view>
					<view class="value">{{data.txhash}}</view>
				</view>
				<view class="list" v-if="data.note">
					<view class="title">{{i18n.otherSide}}ID</view>
					<view class="value">{{data.note}}</view>
				</view>
				<view class="list" v-if="data.money">
					<view class="title">{{i18n.amount}}</view>
					<view class="value">{{data.money}} {{coin_name}}</view>
				</view>
				<template v-if="data.exchange_coin_name && data.exchange_amount">
					<view class="list">
						<view class="title">{{i18n.exchangeBz}}</view>
						<view class="value">{{data.coin_name}}{{i18n.exchange}}{{data.exchange_coin_name}}</view>
					</view>
					<view class="list">
						<view class="title">{{i18n.exchangeNum}}</view>
						<view class="value">{{toAbs(data.amount)}}{{data.coin_name}}</view>
					</view>
					<view class="list">
						<view class="title">{{i18n.exchangeAmount}}</view>
						<view class="value">{{data.exchange_amount}}{{data.exchange_coin_name}}</view>
					</view>
				</template>
				
				<view class="list">
					<view class="title">{{i18n.time}}</view>
					<view class="value">{{data.createtime}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				data: {},
				point: {},
				time: '',
				coin_name: ''
			}
		},
		onShow() {
			uni.setNavigationBarTitle({
			 title: this.$t('coindetail.details')
			})
		},
		onLoad (e){
			this.coin_name = e.coin_name
			try{
				this.data = JSON.parse(e.data)
			}catch(err){
				this.data = {id: e.id},
				this.getData(this.data.id)
			}
		},
		computed:{
			i18n() {
				return this.$t('coindetail');
			}
		},
		methods: {
			toAbs(num) {
				num = Number(num)
				return Math.abs(num)
			},
			getData(log_id) {
				this.$get('api/bill/logDetail', {log_id}).then(res=>{
					if(res.code == 200){
						this.data = Object.assign(this.data, res.data)
					}else{
						this.$toast(res.msg)
					}
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
	page{height: 100%;}
	.card-body {
		flex: 1;
		padding-top: 20upx;
		.list {
			display: flex;
			padding: 24upx 0;
			align-items: center;
			justify-content: space-between;
		}
		.title {
			font-weight:400;
			font-size:28upx;
			color:var(--txt-color);
		}
		.value {
			font-size:28upx;
			font-weight:400;
		}
	}
	.money {
		font-size:40upx;
		font-weight:bold;
		color:var(--theme-color);
		margin-top: 30upx;
	}
	.success-des {
		font-size:28upx;
		font-weight:bold;
		margin-top: 20upx;
	}
	.success-icon {
		width: 80upx;
		height: 80upx;
	}
	.card-header {
		height: 350upx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		border-bottom: 2upx dashed var(--border);
	}
	.card {
		background-color: var(--block-color);
		border-radius:20upx;
		padding: 30upx;
		display: flex;
		flex-direction: column;
		box-shadow:0px 2px 4px rgba(0,0,0,0.16);
	}
	.page {
		padding: 30upx;
	}
</style>
